package itbour.onetouchshow.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;

import itbour.onetouchshow.R;
import itbour.onetouchshow.adapter.base.BaseAdapterHelper;
import itbour.onetouchshow.adapter.base.recycler.RecyclerAdapter;
import itbour.onetouchshow.bean.VideoConditionBean;

/**
 * Created by guoh on 2018/3/28.
 * 功能描述：
 * 需要的参数：
 */

public class FilterAdapter extends RecyclerAdapter<VideoConditionBean.Option> {
    private onItemClickListener listener;

    public FilterAdapter(Context context) {
        super(context, R.layout.item_video_filter);
    }

    @Override
    protected void convert(BaseAdapterHelper helper, VideoConditionBean.Option item, int position) {
        if (item.isSelected()) {
            helper.setBackgroundRes(R.id.ll_layout, R.drawable.filter_selected_style);
        } else {
            helper.setBackgroundRes(R.id.ll_layout, R.color.app_status_bar_color);
        }

        helper.setTextColor(R.id.tv_name, item.isSelected() ? context.getResources().getColor(R.color.xiumi_text_color) : Color.WHITE);
        helper.setVisible(R.id.iv_selected_yes, item.isSelected());
        helper.setText(R.id.tv_name, item.getName());
        helper.setTag(R.id.ll_layout, position).setOnClickListener(R.id.ll_layout, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onItemClickListener(Integer.parseInt(v.getTag().toString()), item);
                }
            }
        });

//        RelativeLayout.LayoutParams params= (RelativeLayout.LayoutParams) helper.getView(R.id.ll_layout).getLayoutParams();
//        RelativeLayout layout=helper.getView(R.id.rl_layout);
//        LinearLayout.LayoutParams layoutParams= (LinearLayout.LayoutParams) layout.getLayoutParams();
//        layoutParams.width=params.width;
//        layoutParams.height=params.height;
//        layout.setLayoutParams(layoutParams);

    }

    public void setonItemClickListener(onItemClickListener listener) {
        this.listener = listener;
    }

    public interface onItemClickListener {
        void onItemClickListener(int position, VideoConditionBean.Option option);
    }
}
